package ml.coursedesign.common.lang;

import lombok.Data;

/**
 * @author likeqc.top
 * @date 2021/4/22 13:26
 */
@Data
public class Result {

  private int code;
  private String msg;
  private Object data;
  public static Result succ() {
    return succ(StatusCode.OK, "操作成功",null);
  }

  public static Result succ(Object data) {
    return succ(StatusCode.OK, "操作成功", data);
  }

  public static Result succ(int code, String msg, Object data) {
    Result r = new Result();
    r.setCode(code);
    r.setMsg(msg);
    r.setData(data);
    return r;
  }

  public static Result fail() {
    return fail(StatusCode.ERROR, "操作失败", null);
  }
  public static Result fail(String msg) {
    return fail(StatusCode.ERROR, msg, null);
  }

  public static Result fail(String msg, Object data) {
    return fail(StatusCode.ERROR, msg, data);
  }

  public static Result fail(int code, String msg, Object data) {
    Result r = new Result();
    r.setCode(code);
    r.setMsg(msg);
    r.setData(data);
    return r;
  }
}
